<?php
App::uses('AppModel', 'Model');
/**
 * Table Model
 *
 * @property Version $Version
 * @property Colonne $Colonne
 * @property Ligne $Ligne
 * @property Rupture $Rupture
 */
class Table extends AppModel {
/**
 * Validation rules
 *
 * @var array
 */
	public $validate = array(
		'name' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
			'Majuscule' => array(
				'rule' => array('majuscule'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'version_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
	);

/**
 * Contrôles
 *
 * RLEB
 */
	function majuscule($check) {       
		// le tableau $check est passé en utilisant le nom du champ de formulaire comme clé        
		// nous devons extraire la valeur pour rendre la fonction générique        
		$valeur = array_values($check);        
		$valeur = $valeur[0];        
		return  ($valeur == strtoupper($valeur));    
	}




	//The Associations below have been created with all possible keys, those that are not needed can be removed

/**
 * belongsTo associations
 *
 * @var array
 */
	public $belongsTo = array(
		'Version' => array(
			'className' => 'Version',
			'foreignKey' => 'version_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);

/**
 * hasMany associations
 *
 * @var array
 */
	public $hasMany = array(
		'Colonne' => array(
			'className' => 'Colonne',
			'foreignKey' => 'table_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),
		/*'Ligne' => array(
			'className' => 'Ligne',
			'foreignKey' => 'table_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),*/
		'Rupture' => array(
			'className' => 'Rupture',
			'foreignKey' => 'table_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	);

}
